package br.ufcg.les;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ContactLocation extends Activity {
	Button btPesquisar, btAddcontato;
	EditText etnomePesquisa;
	TextView tvNome, tvTelefone, tvEmail;
	ContactManager cm = new ContactManager();

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.contact_location);
		btPesquisar = (Button) findViewById(R.id.btPesquisarNome);
		btAddcontato = (Button) findViewById(R.id.btAddContato);
		etnomePesquisa = (EditText) findViewById(R.id.etnomePesquisa);
		tvNome = (TextView) findViewById(R.id.tvNomePesquisado);
		tvTelefone = (TextView) findViewById(R.id.tvTelefone);
		tvEmail = (TextView) findViewById(R.id.tvEmail);

		btPesquisar.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				pesquisarcontato(etnomePesquisa);

			} 

			private void pesquisarcontato(EditText etnomePesquisa) {
				for (String contato : ContactManager.contactList) {
					if (contato.equals(etnomePesquisa)) {
						tvNome.setText(ContactsContract.Contacts.DISPLAY_NAME);
					}
				}
			}

		});

	}
}
